package operation.impl;

import book.Book;
import book.BookList;
import operation.IOperation;

import java.util.Scanner;

/**
 * 归还图书
 */
public class ReturnOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        System.out.println("请输入要归还的图书：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if(name.equals(book.getName())){
                bookList.getBook(i).setBorrowed(false);
                System.out.println("恭喜您，归还图书成功!");
                return;
            }
        }
        System.out.println("不好意思，找不到您要归还的书籍,再去别的地方看看呢。");
    }
}
